<template>
  <div>
    <div class="list">
      <div class="message-item" v-for="(item, index) in list" :key="index" @click="$router.push(item.path)">
        <div class="left">
          <img :src="item.img" alt="" width="100%">
          <div class="dot" v-if="times['new' + (index + 1)] === 2"></div>
        </div>
        <div class="right">
          <span class="title">{{ item.title }}</span>
          <span class="time">{{ times['mess' + (index + 1)] }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import api from '@/api'
export default {
  name: 'index',
  data () {
    return {
      times: {},
      list: [
        {img: require('@/assets/img/icon-message1.png'), title: '课程通知', time: '2019.08.09', path: '/message/course'},
        {img: require('@/assets/img/icon-message2.png'), title: '活动通知', time: '2019.08.09', path: '/message/ordinary/2'},
        {img: require('@/assets/img/icon-message3.png'), title: '系统消息', time: '2019.08.09', path: '/message/ordinary/3'}
      ]
    }
  },
  methods: {
    // 消息首页  agencyMessageIndex
    select () {
      let params = {
        id: JSON.parse(sessionStorage.getItem('user')).id
      }
      api.agencyMessageIndex({
        params,
        callback: res => {
          this.times = res.data.data
        }
      })
    }
  },
  created () {
    this.select()
  }
}
</script>

<style scoped>
  .message-item{
    border-bottom: 1px solid #999;
    display: flex;
    padding: 10px 15px;
    align-items: center;
  }
  .message-item .left{
    width: 26px;
    height: 26px;
    flex-grow: 0;
    flex-shrink: 0;
    position: relative;
  }
  .message-item .right{
    height: 50px;
    flex-grow: 1;
    flex-shrink: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-left: 10px;
  }
  .message-item .right .title{
    font-size:18px;
    font-family:PingFang SC;
    font-weight:bold;
    line-height:25px;
    color:rgba(26,29,32,1);
  }
  .message-item .right .time{
    font-size:13px;
    font-family:PingFang SC;
    font-weight:400;
    line-height:18px;
    color:rgba(102,102,102,1);
  }
</style>
